package edu.dlust.trading_platform;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import edu.dlust.trading_platform.DataBean.userdata;

public class UserActivity extends AppCompatActivity {
    private ImageView head,home,push;
    private TextView name;
    private LinearLayout release,collect,buy,exit,chat;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_user);

        head = findViewById(R.id.imageView_avatar);
        if (userdata.getImg() != null){
            try {
                head.setImageBitmap(userdata.getImg());
            } catch (Exception e) {
            }
        }

        name = findViewById(R.id.textView_username);
        name.setText(userdata.getName());
        init();
    }
    private void init() {
        home = findViewById(R.id.user_home);
        push = findViewById(R.id.user_push);
        release = findViewById(R.id.user_release);
        collect = findViewById(R.id.user_collect);
        buy = findViewById(R.id.user_buy);
        exit = findViewById(R.id.user_exit);
        chat = findViewById(R.id.user_chat);

        home.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(UserActivity.this,HomePageActivity.class);
                startActivity(intent);
                UserActivity.this.finish();
            }
        });

        push.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(UserActivity.this,PublishActivity.class);
                startActivity(intent);
            }
        });

        release.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(UserActivity.this,MyPublishActivity.class);
                startActivity(intent);
            }
        });

        buy.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(UserActivity.this,BuyActivity.class);
                startActivity(intent);
            }
        });

        exit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(UserActivity.this,LoginActivity.class);
                startActivity(intent);
                UserActivity.this.finish();
            }
        });

        collect.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(UserActivity.this,MySpaceActivity.class);
                startActivity(intent);
            }
        });

        chat.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(UserActivity.this,ChatActivity.class);
                startActivity(intent);
            }
        });
    }
}